package com.wolfeyes.framework.service;


import com.wolfeyes.framework.springsecurity.domain.model.CustomizeUserDetails;
//import com.zgd.springboot.web.manager.RedisManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * CacheUserSessionServiceImpl
 * 使用redis缓存实现的，存储用户会话session
 * @author yanyljava
 * @date 2019-07-19 14:29
 */
//@Service
public class SysUserSessionCacheServiceImpl implements SysUserSessionCacheService  {

//  @Autowired
//  private RedisManager redisManager;

	private static final String USER_SESSION_PREFIX = "USER-SESSION:";
	private static final String USER_TOKEN_TIMESTAMP_PREFIX = "USER-TOKEN-TIMESTAMP:";

	@Override
	public void saveSession(CustomizeUserDetails userDetails, int second) {
		String username = userDetails.getUsername();
		String key = USER_SESSION_PREFIX + username;
		//redisManager.setexToJson(key, second, userDetails);
	}

	@Override
	public CustomizeUserDetails getSessionByUsername(String username) {
		String key = USER_SESSION_PREFIX + username;
		//return redisManager.getFromJson(key, CustomizeUserDetails.class);
		return null;
	}

	@Override
	public void destroySession(String username) {
		String key = USER_SESSION_PREFIX + username;
		String key1 = USER_TOKEN_TIMESTAMP_PREFIX + username;
		//redisManager.del(key, key1);
	}


	@Override
	public void saveTokenTimestamp(String username, long mills) {
		String key = USER_TOKEN_TIMESTAMP_PREFIX + username;
		//redisManager.set(key, String.valueOf(mills));
	}

	@Override
	public Long getTokenTimestamp(String username) {
		String key = USER_TOKEN_TIMESTAMP_PREFIX + username;
		return null;
		//return Long.valueOf(redisManager.get(key));
	}
	
}


